<template>
	<view :data-theme="theme">
		<view class="card">
			<view style="display: flex;padding: 20rpx;justify-content: space-between;">
				<view class="title">
					商户余额(元)
				</view>
				<view class="title-c" style="font-weight: bold;">
					{{applyData.balance}}
				</view>
			</view>
			<view style="display: flex;padding: 20rpx;justify-content: space-between;">
				<view class="title">
					可提现金额(元)
				</view>
				<view class="title-c" style="font-weight: bold;">
					{{applyData.transferBalance}}
				</view>
			</view>
			<view style="display: flex;padding: 20rpx;justify-content: space-between;">
				<view class="title">
					保证金金额(元)
				</view>
				<view class="title-c">
					{{applyData.guaranteedAmount}}
				</view>
			</view>
			<view style="display: flex;padding: 20rpx;justify-content: space-between;">
				<view class="title">
					结算类型
				</view>
				<view class="title-c">
					<radio-group @change="radioChange" style="display: flex;flex-flow: row;">
						<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value">
							<view style="padding: 0 20rpx;">
								<radio :value="item.value" :checked="index === current" />
								<view style="display: inline-block;">{{item.name}}</view>
							</view>
						</label>
					</radio-group>
				</view>
			</view>
			<view style="display: flex;padding: 20rpx;justify-content: space-between;">
				<view class="title">
					真实姓名
				</view>
				<view class="title-c">
					{{applyData.realName}}
				</view>
			</view>
			<view v-if="applyForm.closingType == 'bank'">
				<view style="display: flex;padding: 20rpx;justify-content: space-between;">
					<view class="title">
						开户户名
					</view>
					<view class="title-c">
						{{applyData.bankUserName}}
					</view>
				</view>
				<view style="display: flex;padding: 20rpx;justify-content: space-between;">
					<view class="title">
						开户银行
					</view>
					<view class="title-c">
						{{applyData.bankName}}
					</view>
				</view>
				<view style="display: flex;padding: 20rpx;justify-content: space-between;">
					<view class="title">
						银行账号
					</view>
					<view class="title-c">
						{{applyData.bankCard}}
					</view>
				</view>
			</view>
			<view v-if="applyForm.closingType == 'wechat'">
				<view style="display: flex;padding: 20rpx;justify-content: space-between;">
					<view class="title">
						微信号
					</view>
					<view class="title-c">
						{{applyData.wechatCode}}
					</view>
				</view>
				<view style="display: flex;padding: 20rpx;justify-content: space-between;">
					<view class="title">
						收款二维码
					</view>
					<view class="title-c">
						<u--image :showLoading="true" :src="applyData.wechatQrcodeUrl" width="80px" height="80px"
							class="top_left"></u--image>
					</view>
				</view>
			</view>
			<view v-if="applyForm.closingType == 'alipay'">
				<view style="display: flex;padding: 20rpx;justify-content: space-between;">
					<view class="title">
						支付宝账号
					</view>
					<view class="title-c">
						{{applyData.alipayCode}}
					</view>
				</view>
				<view style="display: flex;padding: 20rpx;justify-content: space-between;">
					<view class="title">
						收款二维码
					</view>
					<view class="title-c">
						<u--image :showLoading="true" :src="applyData.alipayQrcodeUrl" width="80px" height="80px"
							class="top_left"></u--image>
					</view>
				</view>
			</view>
			<view style="display: flex;padding: 20rpx;justify-content: space-between;">
				<view class="title">
					申请金额
				</view>
				<view class="title-c">
					<!-- <u-number-box :min="applyData.transferMinAmount" :max="applyData.transferMaxAmount"
						v-model="applyForm.amount"></u-number-box> -->
						<uni-number-box :min="applyData.transferMinAmount" :max="applyData.transferMaxAmount"
						v-model="applyForm.amount"/>
				</view>
			</view>
			<view style="display: flex;padding: 20rpx;justify-content: space-between;">
				<view class="title">
					金额说明
				</view>
			</view>
			<view style="display: flex;padding: 20rpx;justify-content: space-between;">
				<view class="title-c">
					<!-- <u-alert :title="`最低可提现额度${applyData.transferMinAmount}元,最高可提现额度${applyData.transferMaxAmount}元`"
						type="warning"></u-alert> -->
					<uni-notice-bar :text="`最低可提现额度${applyData.transferMinAmount}元,最高可提现额度${applyData.transferMaxAmount}元`" />
				</view>
			</view>
			<view style="display: flex;padding: 20rpx;justify-content: space-between;">
				<view class="title">
					备注
				</view>
				<view class="title-c">
					<textarea style="border: 1px solid #f2f2f2;" placeholder-style="color:#F76260"
						v-model="applyForm.mark" placeholder="可填写备注" />
				</view>
			</view>
		</view>
		<view class="footer" style="position: fixed;bottom: 0;left: 0;right: 0;display: flex;margin: 20rpx;">
			<button class="bg_color" style="padding: 20rpx;color: #fff;font-weight: bold;flex: 1;"
				@click="toApplyClosing()">立即提现</button>
		</view>
	</view>
</template>

<script>
	import {
		toApplyClosingApi
	} from '@/api/finance.js';
	import {
		setThemeColor
	} from '../../../utils/setTheme';
	let app = getApp();
	export default {
		data() {
			return {
				bgColor: "#ffffff",
				theme: app.globalData.theme,
				applyData: {},
				applyForm: {
					amount: 10,
					mark: '',
					closingType: "bank",
				},
				items: [{
						value: 'bank',
						name: '银行卡',
						checked: 'true'
					},
					{
						value: 'wechat',
						name: '微信'
					},
					{
						value: 'alipay',
						name: '支付宝'
					}
				],
				current: 0,
			};
		},
		onLoad(options) {
			this.bgColor = setThemeColor()
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: this.bgColor,
			});
			let data = JSON.parse(options.data);
			this.applyData = data;
		},
		methods: {
			// 提交结算
			toApplyClosing() {
				toApplyClosingApi(this.applyForm).then((res) => {
					console.log(res)
					if(res.code == 200){
						uni.showToast({
						  title: '提交成功',
						  icon: 'success', // 提示图标，可选值：'success', 'loading', 'none'
						  duration: 2000 // 持续时间，单位为毫秒
						});
					}
				})
			},
			// 所选结算类型
			radioChange(evt) {
				this.applyForm.closingType = evt.detail.value;
			}
		}
	}
</script>

<style lang="scss">
	.bg_color {
		@include main_bg_color(theme);
	}

	.card {
		background-color: #fff;
		margin: 20rpx;
		border-radius: 10rpx;
	}

	.column {
		padding: 20rpx;
		display: flex;
		flex-flow: row;
		text-align: center;
		justify-content: space-between;

		.title {
			display: flex;
			// flex: 1;
			width: 150rpx;
		}

		.title-c {
			display: flex;
			flex: 1;
			justify-content: left;
			// padding-left: 20rpx;
		}
	}
</style>